<?php 
	session_start();
	include("../service/userService.php");
	$username = $_POST['username'];
	$password = md5($_POST['password']);
	
	if (authenticateUser($username, $password, 1) == true) {
		$row = ConnectionManager::getInstance()->fetch(findUserBy($username));
		$_SESSION['username'][0] = $row["USER_ID"];
		$_SESSION['username'][1] = $username;
		$_SESSION['username'][2] = 1; // user type
		
		header("Location: ../admin/index.php");
	} else header("Location: ../admin/login.php?login=fail");
?>
